<template>
  <div class="speech-container">
    <div
      class="speech-wrapper"
      :class="{ reverse: layout === 'right-photo' }"
    >
      <div class="photo-panel">
        <img :src="photo" alt="主任照片" class="director-photo" />
        <div class="vertical-name">{{ name }}</div>
        <ul class="director-info">
          <li v-for="(item, index) in info" :key="index">{{ item }}</li>
        </ul>
      </div>
      <div class="text-panel">
        <div class="speech-text">
          <p v-for="(para, i) in speech" :key="i">{{ para }}</p>
        </div>
        <div class="speech-sign">
          <p>国家工程实验室主任：</p>
          <img :src="signature" alt="签名" class="signature-img" />
          <span class="signature-title">{{ name }} 院士</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
defineProps({
  name: String,
  photo: String,
  signature: String,
  info: Array,
  speech: Array,
  layout: {
    type: String,
    default: 'left-photo' // 可选值：'left-photo' | 'right-photo'
  }
})
</script>

<style scoped>
.speech-container {
  max-width: 1300px;
  margin: 40px auto 100px;
  padding: 0 30px;
}
.speech-wrapper {
  display: flex;
  height: 420px;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.05);
}
.speech-wrapper.reverse {
  flex-direction: row-reverse;
}
.photo-panel {
  background: #a30b1b;
  color: white;
  width: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 25px 15px;
  position: relative;
}
.vertical-name {
  position: absolute;
  right: 20px; /* 控制距离头像右侧的间距，可微调 */
  top: 18%;
  transform: translateY(-50%);
  writing-mode: vertical-rl; /*  竖排书写方向，从上到下 */
  text-orientation: upright; /*  保证每个字保持正立，而不是旋转90° */
  font-size: 20px;
  font-weight: bold;
  color: #ffffff;
  letter-spacing: 4px;
  display: flex; /*  让伪元素与文字成为横向结构 */
  flex-direction: row; /*  横向排列（伪元素在左，文字在右） */
  align-items: center;
  gap: 8px; /* 线条与文字的间距 */
}

.vertical-name::before {
  content: '';
  display: block;
  width: 2px;
  height: 40px;
  background-color: #fff;
  margin: 0 auto 8px;
}

.director-photo {
  width: 180px;
  border-radius: 4px;
  margin-bottom: 15px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
}
.director-info {
  list-style: none;
  padding: 0;
  margin-top: 15px;
  text-align: center;
  font-size: 13px;
  line-height: 1.8;
}
.text-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.speech-text {
  flex: 1;
  padding: 30px 40px;
  font-size: 15px;
  line-height: 2;
  color: #333;
  text-align: justify;
}
.speech-sign {
  text-align: right;
  border-top: 1px solid #eee;
  padding: 12px 40px 15px;
}
.signature-img {
  height: 45px;
  margin-left: 8px;
  vertical-align: middle;
}
.signature-title {
  font-size: 14px;
  margin-left: 6px;
  color: #333;
}
</style>
